<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>角色管理</title>
<script type="text/javascript" src="/res/js/common/jquery.1.9.1.min.js"></script>
<script type="text/javascript" src="/res/js/structure/struture.js"></script> 
<script type="text/javascript" src="/res/js/common/common.js"></script>
<script type="text/javascript" src="/res/third/layer/layer.js"></script>
<link href="/res/css/respective/role/role.css" rel="stylesheet">
</head>
[#assign menucode="roleManage"/]
<body> 
	<div class="warp">
		[#include "/front/common/front_headAzt.html"]
		<div class="backcontent">
			[#include "/front/common/front_leftAzt.html"]
			<div class="back-main">
				<div class="mainContent">
		<div class="mainContentWhite">
			<h1>角色管理</h1>
			<hr style="margin-bottom: 4px;">
			<div>
				 <button class="sav" style="float: right;margin-bottom: 4px;height: 32px;" onclick="addrole();">添加角色</button>
			</div>
			<table class="table noBorder">
				<thead style="background: #f2f2f2;">
					<tr>
						<th style="width: 30%;">角色名称</th>
						<th style="width: 40%;">角色成员</th>
						<th style="width: 30%;">操作</th>
					</tr>
				</thead>
				<tbody>
					<!--默认显示8行-->
					[#if notDefaultRolesPage?? && notDefaultRolesPage.list?size>0]
					[#list notDefaultRolesPage.list as nonRoles]
					<tr>
						<td>${nonRoles.name!}</td>
						<td>
							<i class="personData">
							[#if nonRoles.users?? && nonRoles.users?size>0]
							[#list nonRoles.users as user]
								<em>[#if user.realName?? && user.realName?length>0]${user.realName!}[#elseif user.mobile??]${user.mobile!}[#else]${user.email!}[/#if]</em>
							[/#list]
							[/#if]
							</i> 
						</td>
						<td class="oprea">
							<i class="addData"></i>
							<a href="/employee/toAddUserView?roleId=${nonRoles.id!}">添加员工</a>
							<i class="modiData"></i>
							<a href="/orgstruct/addrole?roleId=${nonRoles.id!}">修改</a>
							<i class="delData"></i>
							<a class="delRole" onclick="delRole(${nonRoles.id!});" href="javascript:void(0);">删除</a>
						</td>
					</tr> 
					[/#list]
					[/#if]
				</tbody>
			   <tfoot class="goFenYe">
			[@fenye p = notDefaultRolesPage form = 'infoForm' /]
			</tfoot>
			</table>  
		</div>
	</div>
			</div>
			<!-- 底部菜单-->
			[#include "/front/common/front_footerAzt.html"]
		</div>
	</div>
	<script type="text/javascript">
	function addrole(){
		location.href="/orgstruct/addrole";
	}
	function delRole(roleId){
	   	$.ajax({
			type : "post",
			dataType : "json",
			url : "/orgstruct/checkrole",
			data :{'roleId' :roleId},
			success : function(data) {//成功的时候调用
				if(data.success){
					layer.open({
						   title:'提示'
						  ,content: '是否确定删除角色？'
						  ,btn: ['确定', '取消']
						  ,yes: function(index, layero){
							 	$.ajax({
									type : "post",
									dataType : "json",
									url : "/orgstruct/delrole",
									data :{'roleId' :roleId},
									success : function(data) {
										location.href="/orgstruct/roleManage";
									}
							 	});
						  },btn2: function(index, layero){
						  }
						  ,cancel: function(){ 
						    //右上角关闭回调
						  }
						});
			     
				}else{
					if(data.obj==1){
						layer.open({
							   title:'提醒'
							  ,content: '该角色无法删除，请先处理员工管理中的员工申请'
							  ,btn: ['去处理', '取消']
							  ,yes: function(index, layero){
								  location.href="/employee/employeeApply_list";
							  },btn2: function(index, layero){
							  }
							  ,cancel: function(){ 
							    //右上角关闭回调
							  }
							});
					}else if(data.obj==2){
						layer.open({
							   title:'提醒'
							  ,content: '无法删除该角色。请先将员工移动至其他角色或将员工删除后再删除该角色。'
							  ,btn: ['进入员工管理', '取消']
							  ,yes: function(index, layero){
								  location.href="/employee/employee_list";
							  },btn2: function(index, layero){
							  }
							  ,cancel: function(){ 
							    //右上角关闭回调
							  }
							});
					}
				}
			}
		});
	}
	</script>
</body>
</html>
